const { DataTypes } = require('sequelize');
const sequelize = require('../config/database');

// 定义Tag模型
const Tag = sequelize.define('Tag', {
  id: {
    type: DataTypes.INTEGER,
    autoIncrement: true,
    primaryKey: true
  },
  name: {
    type: DataTypes.STRING(50),
    allowNull: false,
    unique: true,
    comment: '标签名称（中文）'
  },
  count: {
    type: DataTypes.INTEGER,
    defaultValue: 0,
    comment: '使用该标签的包数量'
  }
}, {
  tableName: 'tags',
  indexes: [
    { name: 'idx_count', fields: ['count'] }
  ]
});

module.exports = Tag;